package com.tianxiang.dao;

import java.util.List;

import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;

import com.tianxiang.hibernatesession.HibernateSessionFactory;
import com.tianxiang.model.Admin;
import com.tianxiang.model.User;

public class AdminDao {
	Session getSession() {// 获取session
		return HibernateSessionFactory.getSession();
	}

	@SuppressWarnings("unchecked")
	public List<Admin> findByProperty(String propertyName, Object value) {
		try {
			String queryString = "from Admin as s where s." + propertyName
					+ "=?";
			Query queryObject = getSession().createQuery(queryString);
			queryObject.setParameter(0, value);
			return queryObject.list();
		} catch (HibernateException e) {
			throw e;
		}
	}
	

}
